/*!
 * FrePPLe theme (https://frepple.com)
 *
 * Bootstrap v5.2.3 (https://getbootstrap.com/)
 * Copyright 2011-2022 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
 */

// 1. Include functions first (so you can manipulate colors, SVGs, calc, etc)
@import "../../../../node_modules/bootstrap/scss/functions";

// 2. Include frePPLe theme-specific definitions
@import "theme";

// 3. Include remainder of required parts
@import "../../../../node_modules/bootstrap/scss/variables";
@import "../../../../node_modules/bootstrap/scss/maps";
@import "../../../../node_modules/bootstrap/scss/mixins";
@import "../../../../node_modules/bootstrap/scss/root";

// 4. Include any optional Bootstrap components
@import "../../../../node_modules/bootstrap/scss/utilities";
@import "../../../../node_modules/bootstrap/scss/root";
@import "../../../../node_modules/bootstrap/scss/reboot";
@import "../../../../node_modules/bootstrap/scss/type";
@import "../../../../node_modules/bootstrap/scss/images";
@import "../../../../node_modules/bootstrap/scss/containers";
@import "../../../../node_modules/bootstrap/scss/grid";
@import "../../../../node_modules/bootstrap/scss/tables";
@import "../../../../node_modules/bootstrap/scss/forms";
@import "../../../../node_modules/bootstrap/scss/buttons";
@import "../../../../node_modules/bootstrap/scss/transitions";
@import "../../../../node_modules/bootstrap/scss/dropdown";
@import "../../../../node_modules/bootstrap/scss/button-group";
@import "../../../../node_modules/bootstrap/scss/nav";
@import "../../../../node_modules/bootstrap/scss/navbar";
@import "../../../../node_modules/bootstrap/scss/card";
@import "../../../../node_modules/bootstrap/scss/accordion";
@import "../../../../node_modules/bootstrap/scss/breadcrumb";
@import "../../../../node_modules/bootstrap/scss/pagination";
@import "../../../../node_modules/bootstrap/scss/badge";
@import "../../../../node_modules/bootstrap/scss/alert";
@import "../../../../node_modules/bootstrap/scss/progress";
@import "../../../../node_modules/bootstrap/scss/list-group";
@import "../../../../node_modules/bootstrap/scss/close";
@import "../../../../node_modules/bootstrap/scss/toasts";
@import "../../../../node_modules/bootstrap/scss/modal";
@import "../../../../node_modules/bootstrap/scss/tooltip";
@import "../../../../node_modules/bootstrap/scss/popover";
@import "../../../../node_modules/bootstrap/scss/carousel";
@import "../../../../node_modules/bootstrap/scss/spinners";
@import "../../../../node_modules/bootstrap/scss/offcanvas";
@import "../../../../node_modules/bootstrap/scss/placeholders";

@import "../../../../node_modules/bootstrap/scss/utilities/api";

// 5. frepple generic definitions

.breadcrumb-item a {
    color: $navbar-light-color;
}

.card-body table {
    margin-bottom: 0;
}

// Tabs
.nav-tabs {
    .nav-item .nav-link.active {
        border-color: $light;
        border-top-width: 2px;
        border-left: none;
        border-right: none;
    }
}


#nav-menu-header {
    .navbar-brand img {
        height: $navbar-brand-height;
    }

    a.dropdown-item,
    a.nav-link {
        text-transform: capitalize;
    }

    @include media-breakpoint-up(lg) {
        .dropdown:hover .dropdown-menu {
            display: block;
        }

        .dropdown-menu.show {
            display: inherit !important;
        }
    }

    .nav-item {
        user-select: none;
    }
}

.card-header {
    background: $secondary;
}

.card-header-color,
.card-header-color:hover {
    color: var(--bs-card-cap-color);
}


.red {
    color: red;
}

.btn-group-xs>.btn,
.btn-xs {
    padding: .25rem .4rem;
    font-size: .875rem;
    line-height: .5;
    border-radius: .2rem;
}

/* Django admin overrrides. */

.calendarbox,
.calendar,
.calendar-cancel,
.calendar-shortcuts {
    background-color: inherit;
}

.clockbox {
    background-color: inherit;
    padding: 1rem;

    h2 {
        font-size: 12px;
    }
}

.calendar td a:focus,
.timelist a:focus,
.calendar td a:hover,
.timelist a:hover {
    color: inherit;
    font-weight: bold;
}

.calendar table {
    background-color: inherit;
    caption-side: top;
}

form .module input[type=checkbox] {
    @extend .form-check-input;
}

form .module li:has(input[type=checkbox]) {
    list-style: none;
}

/* Gantt charts */

.time {
    vector-effect: non-scaling-stroke;
    stroke-width: 1px;
    stroke: rgb(0, 0, 0);
}

.axis path,
.axis line,
.miniaxis path {
    fill: none;
    stroke: #000;
    shape-rendering: crispEdges;
}

.graphline {
    stroke-width: 2;
    fill: none;
}

.svgheadertext {
    text-anchor: middle;
}

.svgheaderhistory {
    text-anchor: middle;
    font-style: italic;
    font-weight: normal;
}

/* Raw id fields are too small by default. */

.vForeignKeyRawIdAdminField {
    width: 20em;
}

/* Marking of edited and selected items. */

.dirty-cell:not(.nodirty),
input.ng-dirty:not(.nodirty),
.dirty-cell.active:not(.nodirty),
input.ng-dirty.active:not(.nodirty),
.dirty-cell:hover:not(.nodirty),
input.ng-dirty:hover:not(.nodirty) {
    background-color: $danger !important;
    box-shadow: none !important;
}

.edit-cell {
    background-color: yellow !important;
    box-shadow: none !important;
}

tr.ui-state-highlight {
    border: 1px solid $danger !important;
    background: lighten($danger, 15%) !important;
}

// Avatar
img.avatar-sm {
    border-radius: 50%;
    width: 20px;
    height: 20px;
    border: 1px solid $gray-500;
    vertical-align: top;
}

// Hide arrows from number input
input:not(.arrows)::-webkit-outer-spin-button,
input:not(.arrows)::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type=number]:not(.arrows) {
    -moz-appearance: textfield;
}

// Accordion - we want them to look like a series of panels, instead of a big continuous pile

.accordion-item {
    border-radius: $accordion-border-radius !important;
    margin-bottom: ($spacer * .25) !important;
}

.accordion-button {
    border-radius: $accordion-border-radius !important;
}

// Search box
div.tt-menu.tt-open {
    width: 150%;
}

.tt-menu {
    @extend .dropdown-menu;
    max-height: 500px;
    overflow-y: auto;
}

div.tt-dataset.tt-dataset-search {
    background-color: $dropdown-bg;

    li.tt-suggestion.tt-selectable {
        padding-bottom: 2px;
        padding-top: 2px;
        background-color: $dropdown-bg;
        line-height: $line-height-base;
        display: block;
        list-style-type: none;

        a:link,
        a:visited {
            background-color: inherit;
            color: $dropdown-link-color;
            font-size: $font-size-base;
            /* fix django admin form problems */
            padding-left: 16px;
            text-align: left;
        }
    }

    li.tt-suggestion.tt-selectable a {
        display: block;
        white-space: nowrap;
        overflow: hidden;
    }

    li.tt-suggestion.tt-selectable div {
        position: relative;
        top: -1em;
        margin-top: -4px;
        margin-right: 5px;
        float: right;
    }

    li.tt-suggestion.tt-selectable:hover {
        background-color: $dropdown-link-hover-bg;

        a:link:hover {
            background-color: inherit;
            color: $dropdown-link-hover-color;
            padding-left: 16px;
            text-align: left;
        }
    }

    span.tt-suggestion.tt-selectable {
        p {
            margin-top: 5px;
            margin-bottom: 1px;
            text-align: center;
            background-color: $input-bg;
        }

        li.divider {
            height: 1px;
            margin-bottom: 2px;
            margin-top: 1px;
            overflow: hidden;
            background-color: $dropdown-divider-bg;
        }
    }
}

/* Graph cell in pivot grid */

.graphcell {
    margin-top: 2px;
    margin-bottom: 2px;
}


/* Jqgrid */

.cbox {
    @extend .form-check-input;
}

.ui-jqdialog {
    font-size: $font-size-base;
    // TODO padding: $padding-base-vertical $padding-base-horizontal;

    .custom-dlg-header {
        background-color: $table-bg;
        background-color: $modal-content-bg;
        border-top-left-radius: $border-radius-lg;
        border-top-right-radius: $border-radius-lg;
    }

    .searchFilter .form-control {
        padding: 0.375rem 0.75rem;
        height: auto !important;
    }

    td.first {
        min-width: 1.5rem;
    }

    .ui-jqdialog-titlebar {
        padding: $modal-inner-padding;
        position: relative;
        font-size: $font-size-base;
        border-left: 0 none;
        border-right: 0 none;
        border-top: 0 none;
        background-color: inherit !important;
    }

    .custom-dlg-header {
        background-color: $modal-content-bg;
        border-top-left-radius: $border-radius-lg;
        border-top-right-radius: $border-radius-lg;
    }
}

.ui-jqdialog.ui-jqgrid-bootstrap .ui-jqdialog-titlebar {
    font-size: $h4-font-size;
    font-family: inherit;
    font-weight: 500;
    color: inherit;
}

.ui-jqdialog-content {
    border: 0;
    background: $modal-content-bg;
    height: auto;

    .CaptionTD {
        padding: $modal-inner-padding;
    }
}

.ui-jqgrid {
    .ui-separator {
        height: 12px;
        border-left: 1px solid $table-border-color;
        border-right: 1px solid $table-border-color;
        margin: -1px;
        float: right;
    }

    >.ui-jqgrid-view {
        font-size: $font-size-base;
    }

    tr.jqgrow,
    tr.jqgroup,
    tr.jqfoot,
    tr.ui-subgrid {
        >td {
            overflow: hidden;
            white-space: nowrap;
            height: $input-height-sm;
            border-top: 0 none;
            border-bottom-width: 1px;
            border-bottom-style: solid;
        }
    }

    .ui-jqgrid-btable td.jqgrid-rownum {
        padding: $table-cell-padding-y-sm $table-cell-padding-x-sm;
    }
}

.ui-jqgrid.ui-jqgrid-bootstrap {
    border: 1px solid $table-border-color;
    border-radius: $border-radius-lg;

    tr.jqgfirstrow {
        >td {
            padding: 0 $table-cell-padding-x;
        }
    }

    tr.jqgrow,
    tr.jqgroup,
    tr.jqfoot {
        >td {
            padding: $table-cell-padding-y-sm $table-cell-padding-x-sm;
        }
    }

    .custom-title-div {
        background-color: $table-bg;
    }

    td[role=gridcell]:has(div.invStatus) {
        // Status color cells need to occupy the full center
        // This is NOT working in Firefox...
        padding: 0 !important;
    }

    .invStatus {
        // Status color text should be centered in the cell
        height: 100%;
        @extend .d-flex;
        @extend .align-items-center;
        @extend .justify-content-center;
    }

    td input {
        padding: 1px 2px 1px 2px !important;
    }

    .ui-jqgrid-titlebar,
    ui-jqgrid-errorbar {
        font-size: $h4-font-size;
        font-family: inherit;
        font-weight: 500;
        color: inherit;
    }

    >.ui-jqgrid-view {
        font-size: $font-size-base;
    }

    >.ui-jqgrid-pager {
        font-size: $font-size-base;
    }

    .ui-pager-control .ui-pg-input,
    .ui-pager-control .ui-pg-selbox {
        padding: ($spacer * .25);
    }
}

.g-menu-item {
    @extend .dropdown-item;
}

// Link to password change form on the user edit screen

div.help-block a {
    text-decoration: underline;
    font-weight: bold;
}

// Search filter

h1 small {
    display: inline-block;
    line-height: 2;
}

#filterform {

    padding-left: ($spacer * 0.5);
    border-radius: $border-radius-sm;

    .badge {
        background: $gray-600;
        font-weight: $font-weight-normal;
    }

    .list-group {
        width: auto;
        position: absolute;
        top: 2.25rem;
        z-index: 4999;
        white-space: nowrap;
    }

    .dropdown-item {
        border: none;
        line-height: 2em;
        padding-bottom: 1px;
        padding-top: 1px;
    }

    .input-group {
        display: inline-table;
        vertical-align: middle;

        .input-group-addon,
        .input-group-btn,
        .form-control {
            width: auto !important;
        }
    }

    .badge input {
        color: $gray-600;
        padding-left: 0.25rem;
        padding-right: 0.25rem;
        padding-top: 0;
        padding-bottom: 0;
        display: inline;
        width: auto;
    }

    .fa-times {
        cursor: pointer;
    }
}

// Circle for the wizard

.circle {
    width: 1.2em;
    height: 1.2em;
    border-radius: 0.6em;
    color: #fff;
    text-align: center;
    background: $primary;
    display: inline-block;
}


// Kanban styles

#kanban {
    white-space: nowrap;
    user-select: none;

    .badge {
        color: $badge-color;
        background-color: $primary;
    }

    .column {
        cursor: pointer;
        padding-left: 5px;
        padding-right: 5px;
    }
}

// Calendar

#calendar {

    .scrollable {
        width: 100%;
        overflow-x: hidden;
        overflow-y: scroll;
    }

    .table-fixed {
        table-layout: fixed;
    }

    .no-event-label {
        font-weight: bold;
        color: darkgrey;
        text-align: center;
    }

    .event-detail-container {
        border-top: 2px darkgrey solid;
    }

    .event-detail {
        cursor: pointer;
        white-space: nowrap;
        text-overflow: ellipsis;
    }

    .calendar-header {
        text-align: center;
        padding-top: 5px;
        font-weight: bold;
    }

    .calendar-hour-column,
    .calendar-week-column {
        width: 50px;
    }

    .calendar-sort-column {
        cursor: pointer;
        text-transform: capitalize;
    }

    .calendar-navbar {
        margin-bottom: 5px;
    }

    .calendar-event-wrap {
        position: relative;
        height: 100%;
    }

    .calendar-event {
        position: absolute;
        padding: 2px;
        cursor: pointer;
        z-index: 900;
    }

    .calendar-event-inner {
        overflow: hidden;
        height: 100%;
        width: 100%;
        padding: 5px;
        line-height: 15px;
        border-radius: 4px;
        margin-bottom: 8px;
    }

    .calendar-event-inner p {
        margin: 0 0 2px !important;
    }

    .calendar-cell {
        padding: 0 !important;
        height: 37px;
    }

    .weekview-allday-label,
    .dayview-allday-label {
        float: left;
        height: 100%;
        line-height: 50px;
        text-align: center;
        width: 50px;
        border: 1px solid #ddd;
        border-right-width: 0;
    }

    .weekview-allday-content-wrapper,
    .dayview-allday-content-wrapper {
        margin-left: 50px;
        overflow-x: hidden;
        overflow-y: auto;
        height: 100%;
    }

    .weekview-header,
    .monthview-datetable {
        margin-bottom: 0;
    }

    .weekview-header th {
        overflow: hidden;
        white-space: nowrap;
    }

    .weekview-allday-table,
    .dayview-allday-table {
        height: 52px;
    }

    .weekview-allday-content-table,
    .dayview-allday-content-table {
        min-height: 100%;
        margin-bottom: 0;
    }

    .gutter-column {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    @media (max-width: 750px) {

        .weekview-allday-label,
        .dayview-allday-label,
        .calendar-hour-column,
        .calendar-week-column {
            width: 32px;
        }

        .weekview-allday-label,
        .dayview-allday-label {
            padding-top: 4px;
        }

        .table>tbody>tr>td.calendar-hour-column,
        .table>thead>tr>th.weekview-header-label {
            padding-left: 0;
            padding-right: 0;
            font-size: 12px;
            line-height: 12px;
            vertical-align: middle;
        }

        .weekview-allday-label,
        .dayview-allday-label {
            line-height: inherit;
        }

        .weekview-allday-content-wrapper,
        .dayview-allday-content-wrapper {
            margin-left: 32px;
        }

        .calendar-event-inner {
            font-size: 12px;
        }
    }
}

// Cards in calendar and kanban views

#kanban .column-body,
#calendar {

    .card {
        user-select: text;
        cursor: pointer;
        text-align: left;
        padding: 5px;
        margin-bottom: 0;
    }

    .card-kanban {
        margin-bottom: 8px;
    }

    .card-month {
        padding: 2px;
        margin-bottom: 8px;
    }

    .card-week {
        overflow-y: hidden;
    }

    .card-day {
        overflow-y: hidden;
    }

    .card p {
        margin: 0 0 2px !important;
    }

    .card .form-control {
        padding: 1px 6px;
        line-height: normal;
        height: auto;
    }

    .card table {
        background-color: transparent;
    }

    .card table td.dirty {
        background: $danger;
    }

    .card.active {
        background-color: $table-hover-bg;
    }

    .card-label {
        text-transform: capitalize;
        text-align: right;
        padding-right: 5px;
    }
}

.fill-primary {
    fill: $primary;
}

.btn.active .fill-primary {
    fill: var(--#{$prefix}btn-active-color);
}

.btn:hover .fill-primary {
    fill: var(--#{$prefix}btn-hover-color);
}

.fill-primary-light {
    fill: lighten($primary, 20%);
}

.stroke-primary {
    stroke: $primary;
    fill: none;
}

.btn.active .stroke-primary {
    stroke: var(--#{$prefix}btn-active-color);
    fill: none;
}

.btn:hover .stroke-primary {
    stroke: var(--#{$prefix}btn-hover-color);
    fill: none;
}

@mixin getBackground2Steps($color1, $color2, $color3) {
    $r1: ceil(red($color1));
    $g1: ceil(green($color1));
    $b1: ceil(blue($color1));
    $r2: ceil(red($color2));
    $g2: ceil(green($color2));
    $b2: ceil(blue($color2));
    $r3: ceil(red($color3));
    $g3: ceil(green($color3));
    $b3: ceil(blue($color3));
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' preserveAspectRatio='none' width='500' height='10' viewBox='0 0 500 100'><path fill='rgb(" + $r1 + "," + $g1 + "," + $b1 + ")' stroke-width='2' stroke='rgb(" + $r3 + "," + $g3 + "," + $b3 + ")' d='m0,0 h225 l25,50 l-25,50 h-225 z'/><path fill='rgb(" + $r2 + "," + $g2 + "," + $b2 + ")' stroke-width=' 2' stroke=' rgb(" + $r3 + "," + $g3 + "," + $b3 + ")' d=' m225, 0 h275 v100 h-275 l25, -50 z'/></svg>");
    background-size: 100% 100%;
    background-color: transparent;
}

@mixin getBackground3Steps($color1, $color2, $color3, $color4) {
    $r1: ceil(red($color1));
    $g1: ceil(green($color1));
    $b1: ceil(blue($color1));
    $r2: ceil(red($color2));
    $g2: ceil(green($color2));
    $b2: ceil(blue($color2));
    $r3: ceil(red($color3));
    $g3: ceil(green($color3));
    $b3: ceil(blue($color3));
    $r4: ceil(red($color4));
    $g4: ceil(green($color4));
    $b4: ceil(blue($color4));
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' preserveAspectRatio='none' width='500' height='10' viewBox='0 0 500 100'><path fill='rgb(" + $r1 + "," + $g1 + "," + $b1 + ")' stroke-width='2' stroke='rgb(" + $r4 + "," + $g4 + "," + $b4 + ")' d='m0,0 h141 l25,50 l-25,50 h-141 z'/><path fill='rgb(" + $r2 + "," + $g2 + "," + $b2 + ")' stroke-width='2' stroke='rgb(" + $r4 + "," + $g4 + "," + $b4 + ")' d='m141,0 h166 l25,50 l-25,50 h-166 l25,-50 z'/><path fill='rgb(" + $r3 + "," + $g3 + "," + $b3 + ")' stroke-width='2' stroke='rgb(" + $r4 + "," + $g4 + "," + $b4 + ")' d='m307,0 h194 v100 h-194 l25,-50 z'/></svg>");
    background-size: 100% 100%;
    background-color: transparent;
}

.wizard-1-of-2 table,
.wizard-2-of-2 table,
.wizard-1-of-3 table,
.wizard-2-of-3 table,
.wizard-3-of-3 table {
    background-color: transparent;
}

.wizard-1-of-2 {
    @include getBackground2Steps($secondary, lighten($secondary, 20%), $secondary);
}

.wizard-2-of-2 {
    @include getBackground2Steps(lighten($secondary, 20%), $secondary, $secondary);
}

.wizard-1-of-3 {
    @include getBackground3Steps($secondary, lighten($secondary, 20%), lighten($secondary, 20%), $secondary);
}

.wizard-2-of-3 {
    @include getBackground3Steps(lighten($secondary, 20%), $secondary, lighten($secondary, 20%), $secondary);
}

.wizard-3-of-3 {
    @include getBackground3Steps(lighten($secondary, 20%), lighten($secondary, 20%), $secondary, $secondary);
}

.supply .panel-heading.collapsed {
    opacity: 0.8;
}

// Log file viewer

pre {
    font-size: $font-size-base;
}

// Resize handler

.handle {
    cursor: ns-resize;
    bottom: 0;
}

// Fix date widget in chrome
input[type="date"] {
    appearance: auto;
}

// Draggable widgets
.widget-handle {
    cursor: grab;
}

.widget-handle:active {
    cursor: grabbing;
}